package cn.tedu.spring_security.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
import org.springframework.security.crypto.password.PasswordEncoder;

@Configuration
public class PasswordEncoderConfig {
    /**
     * 为SpringSecurity提供的密码编码器PasswordEncoder
     */
    @Bean
    public PasswordEncoder passwordEncoder() {
        //createDelegatingPasswordEncoder()去自动创建passwordEncoder
        PasswordEncoder passwordEncoder =
                PasswordEncoderFactories.createDelegatingPasswordEncoder();
        //System.out.println(passwordEncoder.getClass().getName());
        return passwordEncoder;
    }
}
